import java.util.Scanner;

public class common_divisor {
    public static void main(String[] args) {
        Scanner num = new Scanner(System.in);
        int a = num.nextInt();
        int b = num.nextInt();
        int c = a < b ? a : b;
        int i;
        for(i = 1;i <= c; i++)
        {
            if(a % c == 0 && b % c == 0)
            {
                System.out.printf("%d\n",c);
                break;
            }
            c/=2;
        }



    }
}
